import psycopg2
import pymysql
'''
    用于获取数据库连接和游标
'''
def get_conn_pg(host, port, user, passwd, db):
    """
    返回连接信息 pg数据库
    :return: 连接, 游标
    """

    # 获取连接
    conn = psycopg2.connect(host=host, port=port, user=user, password=passwd, database=db, connect_timeout=10)
    # 获取游标
    cursor = conn.cursor()

    # 返回连接和游标
    return conn, cursor


def get_conn_mysql(host, port, user, passwd, db):
    """
    返回连接信息 mysql数据库
    :return: 连接, 游标
    """

    # 获取连接
    conn = pymysql.connect(host=host, port=port, user=user, password=passwd, database=db, connect_timeout=10)
    # 获取游标
    cursor = conn.cursor()

    # 返回连接和游标
    return conn, cursor
